<?php 
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

mm_showMyFileName( __FILE__ );

require_once( CLASSPATH . "ps_restaurant.php" );
require_once( CLASSPATH . "htmlTools.class.php" );
require_once ( CLASSPATH. 'ps_user.php');
$ps_user = new ps_user;       

if( vmIsJoomla( '1.5' ) ) {
    // Set the validation value
    $validate = JUtility::getToken();
} else {
    $validate =  function_exists( 'josspoofvalue' ) ? josSpoofValue(1) : vmSpoofValue(1);
}

$vendor_id = vmGet( $_REQUEST, 'vendor_id');
//$vendor_id = 9;
$submitType = 'restaurantAdd';
$user =& JFactory::getUser();
$user->_perms=$ps_user->getUserInfomations($user->get('id'))->record[0]->perms;
$user->_vendor_id=$ps_user->getUserInfomations($user->get('id'))->record[0]->vendor_id;
$db_tmp = null;
if(($user->get('id')!='')&&($user->_perms=='storeadmin'))
{
    if (!empty($vendor_id)) 
    {
        $submitType = 'restaurantUpdate';
        $db_tmp = ps_restaurant::edit($vendor_id);
    }
}
?>
<script language="javascript">

function reg_restaurant() {
    var obj = new Object();
    obj.cuisineHTML = '<?php echo ps_restaurant::getCuisineType(); ?>';
    obj.dayHTML = '<?php echo ps_restaurant::getDayHtml(); ?>';
    obj.hourHTML = '<?php echo ps_restaurant::getHourHtml(); ?>';
    obj.ampmHTML = '<?php echo ps_restaurant::getAmPmHtml(); ?>';
    obj.minuteHTML = '<?php echo ps_restaurant::getMinuteHtml(); ?>';
    
    obj.init = function() {
        var delivery = '<?php echo (isset($db_tmp)) ? $db_tmp->p("vendor_delivery") : "" ?>';
        if (delivery == '1') {
            $('vendor_delivery_yes').checked = true;
        } else {
            $('vendor_delivery_no').checked = true;
        }
        
        var vendor_submit_type = '<?php echo $submitType; ?>';
        if (vendor_submit_type == 'restaurantAdd') {
            $('btnReg').className = '';
            $('btnReg').disabled = 'disabled';
        }
    }
    
    obj.keyKitchenHour = '<?php echo count($db_tmp->kitchens->record); ?>';
    obj.getDateTimeScript = function() {
        obj.keyKitchenHour++;
        var id = obj.keyKitchenHour;
        
        var sScript = '<div id="dvDateTime'+id+'">';
        sScript += '<table id="tblDateTime'+id+'" cellpadding="1" cellspacing="1" border="0" width="100%">';
        sScript += '<tr>';
        sScript += '<td align="left" width="165px">';
        sScript += '<select id="cboDateFrm'+id+'" name="cboDateFrm'+id+'" class="inputbox" style="width: 110px;">';
        sScript += obj.dayHTML;
        sScript += '</select>';
        sScript += '</td>';
        sScript += '<td align="center" width="15px">to</td>';
        sScript += '<td align="left" width="165px">';
        sScript += '<select id="cboDateTo'+id+'" name="cboDateTo'+id+'" class="inputbox" style="width: 110px;">';
        sScript += obj.dayHTML;
        sScript += '</select>';
        sScript += '</td>';
        sScript += '<td align="left">';
        sScript += '<input class="updown" type="button" value="+" onclick="_reg_restaurant_.addDateTime();" style="width: 25px;"/>&nbsp;';
        sScript += '<input class="updown" type="button" value="-" onclick="_reg_restaurant_.removeDateTime(\'tblDateTime'+id+'\');" style="width: 25px;"/>';
        sScript += '</td>';
        sScript += '</tr>';
        sScript += '<tr>';
        sScript += '<td align="left">';
        sScript += '<select id="cboHourFrm'+id+'" name="cboHourFrm'+id+'" class="inputbox" style="width: 50px;">';
        sScript += obj.hourHTML;
        sScript += '</select>';
        sScript += '&nbsp;:&nbsp;';
        sScript += '<select id="cboMinuteFrm'+id+'" name="cboMinuteFrm'+id+'" class="inputbox" style="width: 50px;">';
        sScript += obj.minuteHTML;
        sScript += '</select>';
        sScript += '<select id="cboAmPmFrm'+id+'" name="cboAmPmFrm'+id+'" class="inputbox" style="width: 50px;">';
        sScript += obj.ampmHTML;
        sScript += '</select>';
        sScript += '</td>';
        sScript += '<td align="center">to</td>';
        sScript += '<td align="left">';
        sScript += '<select id="cboHourTo'+id+'" name="cboHourTo'+id+'" class="inputbox" style="width: 50px;">';
        sScript += obj.hourHTML;
        sScript += '</select>';
        sScript += '&nbsp;:&nbsp;';
        sScript += '<select id="cboMinuteTo'+id+'" name="cboMinuteTo'+id+'" class="inputbox" style="width: 50px;">';
        sScript += obj.minuteHTML;
        sScript += '</select>';
        sScript += '<select id="cboAmPmTo'+id+'" name="cboAmPmTo'+id+'" class="inputbox" style="width: 50px;">';
        sScript += obj.ampmHTML;
        sScript += '</select>';
        sScript += '</td>';
        sScript += '<td><input type="hidden" name="hdnKitchenId'+id+'" id="hdnKitchenId'+id+'" value="0" /></td>';
        sScript += '</tr>';
        sScript += '<tr><td colspan="4"><hr /></td></tr>';
        sScript += '</table>';
        sScript += '</div>';
        
        return sScript;
    }
    
    obj.addDateTime = function() {
        var sScript = obj.getDateTimeScript();
        var dv = document.createElement("div");
        dv.innerHTML = sScript;
        $('dvDateTime').appendChild(dv);
    }
    
    obj.removeDateTime = function(id) {
        var s = obj.getScriptId(obj.keyKitchenHour, 'tblDateTime');
        var arrs = s.split(',');
        if (arrs.length == 1) {
            return;
        }
        
        if (document.getElementById(id)) {
            document.getElementById(id).parentNode.removeChild(document.getElementById(id));
        }
    }
    
    obj.keyDaysClosed = '<?php echo count($db_tmp->daysClosed->record); ?>';
    obj.getDaysClosedScript = function() {
        obj.keyDaysClosed++;
        var id = obj.keyDaysClosed;
        
        var sScript = '<div id="dvDaysClosed'+id+'">'+
                        '<table id="tblDaysClosed'+id+'" cellpadding="1" cellspacing="1" border="0" width="100%">'+
                        '<tr>'+
                        '<td style="font-weight: bold;width:100%;">'+
                        '<input id="txtDateClosed'+id+'" name="txtDateClosed'+id+'" class="inputbox" type="text" value="" style="text-align: center; width: 100px;" readonly=readonly onclick="javascript:gfPop.fShowCalendarCtrl(this, event.clientX, event.clientY);"/>'+
                        '&nbsp;<img class="calendar" alt="calendar" src="libraries/calendar/cal.gif" style="cursor: pointer;" onclick="javascript:gfPop.fShowCalendarCtrl(document.getElementById(\'txtDateClosed'+id+'\'), event.clientX, event.clientY);"/>'+
                                                                      
                        '&nbsp;<input class="updown" type="button" value="+" onclick="_reg_restaurant_.addDaysClosed();" style="width: 25px;"/>&nbsp;'+
                        '<input class="updown" type="button" value="-" onclick="_reg_restaurant_.removeDaysClosed(\'tblDaysClosed'+id+'\');" style="width: 25px;"/>'+

                        '<input type="hidden" name="hdnDaysClosedId'+id+'" id="hdnDaysClosedId'+id+'" value="0" />'+
                        '</td>'+
                        '</tr>'+
                        '</table>'+
                        '</div>';
        
        return sScript;
    }
    
    obj.addDaysClosed = function() {
        var sScript = obj.getDaysClosedScript();
        var dv = document.createElement("div");
        dv.innerHTML = sScript;
        $('dvDaysClosed').appendChild(dv);
    }
    
    obj.removeDaysClosed = function(id) {
        var s = obj.getScriptId(obj.keyDaysClosed, 'tblDaysClosed');
        var arrs = s.split(',');
        if (arrs.length == 1) {
            $('txtDateClosed'+s).value = '';
            return;
        }
        
        if (document.getElementById(id)) {
            document.getElementById(id).parentNode.removeChild(document.getElementById(id));
        }
    }
   
    obj.keyCuisine = '<?php echo count($db_tmp->cuisine->record); ?>';
    obj.getCuisineScript = function() {
        obj.keyCuisine++;
        var id = obj.keyCuisine;
        
        var sScript = '<div id="dvCuisine'+id+'">'+
                        '<table id="tblCuisine'+id+'" cellpadding="1" cellspacing="1" border="0" width="100%">'+
                        '<tr>'+
                        '<td width="140px">'+
                        '<select class="inputbox" id="cboCuisine'+id+'" name="cboCuisine'+id+'" style="width: 200px;">'+
                        obj.cuisineHTML +
                        '</select>'+
                        '</td>'+
                        '<td>'+
                        '<input class="updown" type="button" value="+" onclick="_reg_restaurant_.addCuisine();" style="width: 25px;"/>&nbsp;'+
                        '<input class="updown" type="button" value="-" onclick="_reg_restaurant_.removeCuisine(\'tblCuisine'+id+'\');" style="width: 25px;"/>'+
                        '<input type="hidden" name="hdnCuisineId'+id+'" id="hdnCuisineId'+id+'" value="0" />'+
                        '</td>'+
                        '</tr>'+
                        '</table>'+
                        '</div>';
        
        return sScript;
    }
    
    obj.addCuisine = function() {
        var sScript = obj.getCuisineScript();
        var dv = document.createElement("div");
        dv.innerHTML = sScript;
        $('dvCuisine').appendChild(dv);
    }
    
    obj.removeCuisine = function(id) {
        var s = obj.getScriptId(obj.keyCuisine, 'tblCuisine');
        var arrs = s.split(',');
        if (arrs.length == 1) {
            return;
        }
        if (document.getElementById(id)) {
            document.getElementById(id).parentNode.removeChild(document.getElementById(id));
        }
    }
    
    obj.checkNumber = function(val) {
        for(var i=0;i<val.length;i++) {
            var s = val.substr(i, 1);
            if (isNaN(s)) {
                return false;
            }
        }
        
        return true;
    }
    
    obj.checkInput = function() {
        if ($('vendor_user_name').value == '') {
            alert('You must enter a user name for the restaurant.');
            $('vendor_user_name').focus();
            return;
        }
        
        if ($('vendor_password').value == '') {
            alert('You must enter a password for the restaurant.');
            $('vendor_password').focus();
            return;
        }
        
        if ($('vendor_name').value == '') {
            alert('You must enter a name for the restaurant.');
            $('vendor_name').focus();
            return;
        }
        
        if ($('vendor_phone_1_1').value == '') {
            alert('You must enter a phone 1 for the restaurant.');
            $('vendor_phone_1_1').focus();
            return;
        }
        
        if ($('vendor_phone_1_1').value.length != 3) {
            alert('Phone invalid.');
            $('vendor_phone_1_1').focus();
            return;
        }
        
        var isNum = obj.checkNumber($('vendor_phone_1_1').value);
        if (!isNum) {
            alert('Phone invalid.');
            $('vendor_phone_1_1').focus();
            return;
        }
        
        if ($('vendor_phone_1_2').value == '') {
            alert('You must enter a phone 1 for the restaurant.');
            $('vendor_phone_1_2').focus();
            return;
        }
        
        if ($('vendor_phone_1_2').value.length != 3) {
            alert('Phone invalid.');
            $('vendor_phone_1_2').focus();
            return;
        }
        
        isNum = obj.checkNumber($('vendor_phone_1_2').value);
        if (!isNum) {
            alert('Phone invalid.');
            $('vendor_phone_1_2').focus();
            return;
        }
        
        if ($('vendor_phone_1_3').value == '') {
            alert('You must enter a phone 1 for the restaurant.');
            $('vendor_phone_1_3').focus();
            return;
        }
        
        if ($('vendor_phone_1_3').value.length != 4) {
            alert('Phone invalid.');
            $('vendor_phone_1_3').focus();
            return;
        }
        
        isNum = obj.checkNumber($('vendor_phone_1_3').value);
        if (!isNum) {
            alert('Phone invalid.');
            $('vendor_phone_1_3').focus();
            return;
        }
        
        if ($('vendor_address_1').value == '') {
            alert('You must enter a address for the restaurant.');
            $('vendor_address_1').focus();
            return;
        }
        
        if ($('vendor_city').value == '') {
            alert('You must enter a city for the restaurant.');
            $('vendor_city').focus();
            return;
        }
        
        if ($('vendor_state').value == '') {
            alert('You must enter a state for the restaurant.');
            $('vendor_state').focus();
            return;
        }
        
        if ($('vendor_zip').value == '') {
            alert('You must enter a zip for the restaurant.');
            $('vendor_zip').focus();
            return;
        }
                        
        if($('vendor_delivery_yes').checked == true)
        {
            if(isNaN($('vendor_delivery_fee').value)||$('vendor_delivery_fee').value<=0)
            {
                 alert('You must enter a delivery fee for the restaurant.');
                 $('vendor_delivery_fee').focus();
                 return;
            }
        }
        
        return true;
    }
    
    obj.checkInputByCuisine = function() {
        var ids = $('hdnCuisine').value;
        var arrId = ids.split(',');
        for(var i=0;i<arrId.length;i++) {
            if ($('cboCuisine'+arrId[i]) && $('cboCuisine'+arrId[i]).value == 0) {
                alert('You must select a cuisine for the restaurant.');
                $('cboCuisine'+arrId[i]).focus();
                return false;
            }
        }
        
        return true;
    }
    
    obj.checkInputByKitchenHours = function() {
        var ids = $('hdnKitchen').value;
        var arrId = ids.split(',');
        for(var i=0;i<arrId.length;i++) {
            if ($('cboDateFrm'+arrId[i]) && $('cboDateFrm'+arrId[i]).value == '-1') {
                alert('You must select a kitchen hour for the restaurant.');
                $('cboDateFrm'+arrId[i]).focus();
                return false;
            }
            
            if ($('cboDateTo'+arrId[i]) && $('cboDateTo'+arrId[i]).value == '-1') {
                alert('You must select a kitchen hour for the restaurant.');
                $('cboDateTo'+arrId[i]).focus();
                return false;
            }
            
            if ($('cboHourFrm'+arrId[i]) && $('cboHourFrm'+arrId[i]).value == '-1') {
                alert('You must select a kitchen hour for the restaurant.');
                $('cboHourFrm'+arrId[i]).focus();
                return false;
            }
            
            if ($('cboAmPmFrm'+arrId[i]) && $('cboAmPmFrm'+arrId[i]).value == '-1') {
                alert('You must select a type hour for the restaurant.');
                $('cboAmPmFrm'+arrId[i]).focus();
                return false;
            }
            
            if ($('cboMinuteFrm'+arrId[i]) && $('cboMinuteFrm'+arrId[i]).value == '-1') {
                alert('You must select a kitchen hour for the restaurant.');
                $('cboMinuteFrm'+arrId[i]).focus();
                return false;
            }
            
            if ($('cboHourTo'+arrId[i]) && $('cboHourTo'+arrId[i]).value == '-1') {
                alert('You must select a kitchen hour for the restaurant.');
                $('cboHourTo'+arrId[i]).focus();
                return false;
            }
            
            if ($('cboAmPmTo'+arrId[i]) && $('cboAmPmTo'+arrId[i]).value == '-1') {
                alert('You must select a type hour for the restaurant.');
                $('cboAmPmTo'+arrId[i]).focus();
                return false;
            }
            
            if ($('cboMinuteTo'+arrId[i]) && $('cboMinuteTo'+arrId[i]).value == '-1') {
                alert('You must select a kitchen hour for the restaurant.');
                $('cboMinuteTo'+arrId[i]).focus();
                return false;
            }
        }
        
        return true;
    }
    
    obj.saveData = function() {
        if (!obj.checkInput()) {
            return;
        }
        $('hdnKitchen').value = obj.getScriptId(obj.keyKitchenHour, 'tblDateTime');
        $('hdnDayClosed').value = obj.getScriptId(obj.keyDaysClosed, 'tblDaysClosed');
        $('hdnCuisine').value = obj.getScriptId(obj.keyCuisine, 'tblCuisine');
        
        if (!obj.checkInputByKitchenHours()) {
            return;
        }
        
        if (!obj.checkInputByCuisine()) {
            return;
        }
        
        document.adminForm.submit();
    }
    
    obj.getScriptId = function(keyId, tblId) {
        var sScript = '';
        
        for (var i=0; i<=keyId; i++) {
            var tbl = document.getElementById(tblId+i);
            if (tbl) {
                var key = tbl.id.replace(tblId, '');
                sScript = sScript + ',' + key;
            }
        }
                    
        if (sScript != '') { 
            // Xoa ky tu [,] phia dau chuoi
            sScript = sScript.substring(1 , sScript.length);
        }
                    
        return sScript;
    }
    
    obj.agreeChanged = function() {
        <?php if($submitType == 'restaurantAdd'){?>
        var check = $('chkAgree').checked;
        
        if (check) {
            $('btnReg').className = 'button';
            $('btnReg').disabled = '';
        } else {
            $('btnReg').className = '';
            $('btnReg').disabled = 'disabled';
        }
        <?php }?>
    }
    
    return obj;
}

var _reg_restaurant_ = new reg_restaurant();
window.onload = _reg_restaurant_.init;
</script>
<form action="<?php echo $mm_action_url.basename($_SERVER['PHP_SELF']); ?>" name="adminForm" method="post">
<div>
    <table class="adminform" width="100%">
        <tr> 
            <td colspan="2"><strong><?php if($submitType == 'restaurantAdd'){echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_TITLE');}else{echo $VM_LANG->_('PHPSHOP_RESTAURANT_EDIT_FORM_TITLE');} ?></strong></td>
        </tr>
        <tr>
            <td width="45%" valign="top">
                <table cellpadding="1" cellspacing="1" border="0">
                    <tr>
                        <td width="110px">
                            <span style="font-weight: bold;"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_USER_NAME') ?></span>
                        </td>
                        <td>
                            <input name="vendor_user_name" id="vendor_user_name" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_user_name") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_PASSWORD') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_password" id="vendor_password" class="inputbox textbox" type="password" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_password") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_EMAIL') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_email" id="vendor_email" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_email") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_NAME') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_name" id="vendor_name" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_name") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_PHONE_1') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_phone_1_1" id="vendor_phone_1_1" class="inputbox textbox" type="text" style="width: 30px" maxlength="3" value="<?php echo (isset($db_tmp)) ? $db_tmp->phone_1[0] : ''; ?>"/>
                            <input name="vendor_phone_1_2" id="vendor_phone_1_2" class="inputbox textbox" type="text" style="width: 30px" maxlength="3" value="<?php echo (isset($db_tmp)) ? $db_tmp->phone_1[1] : ''; ?>"/>
                            <input name="vendor_phone_1_3" id="vendor_phone_1_3" class="inputbox textbox" type="text" style="width: 40px" maxlength="4" value="<?php echo (isset($db_tmp)) ? $db_tmp->phone_1[2] : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_PHONE_2') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_phone_2_1" id="vendor_phone_2_1" class="inputbox textbox" type="text" style="width: 30px" maxlength="3" value="<?php echo (isset($db_tmp)) ? $db_tmp->phone_2[0] : ''; ?>"/>
                            <input name="vendor_phone_2_2" id="vendor_phone_2_2" class="inputbox textbox" type="text" style="width: 30px" maxlength="3" value="<?php echo (isset($db_tmp)) ? $db_tmp->phone_2[1] : ''; ?>"/>
                            <input name="vendor_phone_2_3" id="vendor_phone_2_3" class="inputbox textbox" type="text" style="width: 40px" maxlength="4" value="<?php echo (isset($db_tmp)) ? $db_tmp->phone_2[2] : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_FAX') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_fax" id="vendor_fax" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_fax") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_FACEBOOK_LINK') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_facebook_link" id="vendor_facebook_link" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_facebook_link") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_ADDR_1') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_address_1" id="vendor_address_1" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_address_1") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_ADDR_2') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_address_2" id="vendor_address_2" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_address_2") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_CITY') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_city" id="vendor_city" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_city") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_STATE') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_state" id="vendor_state" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_state") : ''; ?>"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_ZIP') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_zip" id="vendor_zip" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_zip") : ''; ?>"/>
                        </td>
                    </tr>
                     <tr>
                        <td>
                            <span style="font-weight: bold;">
                            <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_KEYWORD') ?>
                            </span>
                        </td>
                        <td>
                            <input name="vendor_keyword" id="vendor_keyword" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_keyword") : ''; ?>"/>
                        </td>
                    </tr> 
                </table>
            </td>
            <td width="55%" valign="top">
                <table cellpadding="1" cellspacing="1" border="0" width="100%">
                    <tr>
                        <td width="40%">                           
                            <table>
                                <tr>
                                    <td><span style="font-weight: bold;"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_DELIVERY') ?></span></td>
                                    <td>
                                         <input style="height:10px;" name="vendor_delivery" id="vendor_delivery_yes" class="inputbox textbox" type="radio" value="1" />
                                         <label for="vendor_delivery_yes"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_DELIVERY_YES') ?></label>&nbsp;&nbsp;&nbsp;&nbsp;
                                         <input style="height:10px;" name="vendor_delivery" id="vendor_delivery_no" class="inputbox textbox" type="radio" value="0" />
                                         <label for="vendor_delivery_no"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_DELIVERY_NO') ?></label>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td width="60%">
                             <table>
                                <tr>
                                    <td><span style="font-weight: bold;"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_DELIVERY_FEE') ?>: </span></td>
                                    <td><span style="font-weight: bold;">$</span><input name="vendor_delivery_fee" id="vendor_delivery_fee" size="3" style="width: 30px;" class="inputbox textbox" type="text" value="<?php (isset($db_tmp)) ? $db_tmp->p("amount") : ''; ?>"/></td>
                                </tr>
                             </table>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <span style="font-weight: bold;"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_KITCHENS_HOUR') ?></span>
                            <div id="dvDateTime">
                                <?php
                                if (!isset($db_tmp) || count($db_tmp->kitchens->record) == 0) {
                                ?>
                                <div id="dvDateTime0">
                                    <table id="tblDateTime0" cellpadding="1" cellspacing="1" border="0" width="100%">
                                        <tr>
                                            <td align="left" width="165px">
                                                <select id="cboDateFrm0" name="cboDateFrm0" class="inputbox" style="width: 110px;">
                                                    <?php echo ps_restaurant::getDayHtml(); ?>
                                                </select>
                                            </td>
                                            <td align="center" width="15px">to</td>
                                            <td align="left" width="165px">
                                                <select id="cboDateTo0" name="cboDateTo0" class="inputbox" style="width: 110px;">
                                                    <?php echo ps_restaurant::getDayHtml(); ?>
                                                </select>
                                            </td>
                                            <td align="left">
                                                <input class="updown" type="button" value="+" onclick="_reg_restaurant_.addDateTime();" style="width: 25px;"/>
                                                <input class="updown" type="button" value="-" onclick="_reg_restaurant_.removeDateTime('tblDateTime0');" style="width: 25px;"/>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left">
                                                <select id="cboHourFrm0" name="cboHourFrm0" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getHourHtml(); ?>
                                                </select>
                                                :
                                                <select id="cboMinuteFrm0" name="cboMinuteFrm0" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getMinuteHtml(); ?>
                                                </select>
                                                <select id="cboAmPmFrm0" name="cboAmPmFrm0" class="inputbox" style="width: 48px;font-size: 11px;">
                                                    <?php echo ps_restaurant::getAmPmHtml(); ?>
                                                </select>
                                            </td>
                                            <td align="center">to</td>
                                            <td align="left">
                                                <select id="cboHourTo0" name="cboHourTo0" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getHourHtml(); ?>
                                                </select>
                                                :
                                                <select id="cboMinuteTo0" name="cboMinuteTo0" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getMinuteHtml(); ?>
                                                </select>
                                                <select id="cboAmPmTo0" name="cboAmPmTo0" class="inputbox" style="width: 48px;font-size: 11px;">
                                                    <?php echo ps_restaurant::getAmPmHtml(); ?>
                                                </select>
                                            </td>
                                            <td align="right"><input type="hidden" name="hdnKitchenId0" id="hdnKitchenId0" value="0" /></td>
                                        </tr>
                                        <tr><td colspan="4"><hr /></td></tr>
                                    </table>
                                </div>
                                <?php } else {
                                    for ($i = 0; $i < count($db_tmp->kitchens->record); $i++) {
                                        $obj = $db_tmp->kitchens->record[$i];
                                ?>
                                <div id="dvDateTime<?php echo $i; ?>">
                                    <table id="tblDateTime<?php echo $i; ?>" cellpadding="1" cellspacing="1" border="0" width="100%">
                                        <tr>
                                            <td align="left" width="165px">
                                                <select id="cboDateFrm<?php echo $i; ?>" name="cboDateFrm<?php echo $i; ?>" class="inputbox" style="width: 110px;">
                                                    <?php echo ps_restaurant::getDayHtml($obj->date_from); ?>
                                                </select>
                                            </td>
                                            <td align="center" width="15px">to</td>
                                            <td align="left" width="165px">
                                                <select id="cboDateTo<?php echo $i; ?>" name="cboDateTo<?php echo $i; ?>" class="inputbox" style="width: 110px;">
                                                    <?php echo ps_restaurant::getDayHtml($obj->date_to); ?>
                                                </select>
                                            </td>
                                            <td align="left">
                                                <input type="button" value="+" onclick="_reg_restaurant_.addDateTime();" style="width: 25px;"/>
                                                <input type="button" value="-" onclick="_reg_restaurant_.removeDateTime('tblDateTime<?php echo $i; ?>');" style="width: 25px;"/>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left">
                                                <select id="cboHourFrm<?php echo $i; ?>" name="cboHourFrm<?php echo $i; ?>" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getHourHtml($obj->hour_from); ?>
                                                </select>
                                                :
                                                <select id="cboMinuteFrm<?php echo $i; ?>" name="cboMinuteFrm<?php echo $i; ?>" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getMinuteHtml($obj->minute_from); ?>
                                                </select>
                                                <select id="cboAmPmFrm<?php echo $i; ?>" name="cboAmPmFrm<?php echo $i; ?>" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getAmPmHtml($obj->hour_from); ?>
                                                </select>
                                            </td>
                                            <td align="center">to</td>
                                            <td align="left">
                                                <select id="cboHourTo<?php echo $i; ?>" name="cboHourTo<?php echo $i; ?>" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getHourHtml($obj->hour_to); ?>
                                                </select>
                                                :
                                                <select id="cboMinuteTo<?php echo $i; ?>" name="cboMinuteTo<?php echo $i; ?>" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getMinuteHtml($obj->minute_to); ?>
                                                </select>
                                                <select id="cboAmPmTo<?php echo $i; ?>" name="cboAmPmTo<?php echo $i; ?>" class="inputbox" style="width: 50px;">
                                                    <?php echo ps_restaurant::getAmPmHtml($obj->hour_to); ?>
                                                </select>
                                            </td>
                                            <td align="right"><input type="hidden" name="hdnKitchenId<?php echo $i; ?>" id="hdnKitchenId<?php echo $i; ?>" value="<?php echo $obj->id; ?>" /></td>
                                        </tr>
                                        <tr><td colspan="4"><hr /></td></tr>
                                    </table>
                                </div>
                                <?php } } ?>
                            </div>
                        </td>
                    </tr>
                    <tr>                        
                        <td colspan="2"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_DATE_DESC') ?></td>
                    </tr>
                    <tr> 
                        <td colspan="2">   
                            <span style="font-weight: bold;"> <?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_DAYS_CLOSED') ?></span>                         
                            <div id="dvDaysClosed">
                                <?php
                                if ( !isset($db_tmp) || count($db_tmp->daysClosed->record) == 0) {
                                ?>
                                <div id="dvDaysClosed0">
                                    <table id="tblDaysClosed0" cellpadding="1" cellspacing="1" border="0" width="100%">
                                        <tr>
                                            <td style="font-weight: bold;width: 100%;">
                                                <input id="txtDateClosed0" name="txtDateClosed0" class="inputbox" type="text" value="" style="text-align: center; width: 100px;" readonly=readonly onclick="javascript:gfPop.fShowCalendarCtrl(this, event.clientX, event.clientY);"/>
                                                <img class="calendar" alt="calendar" src="libraries/calendar/cal.gif" style="cursor: pointer;" onclick="javascript:gfPop.fShowCalendarCtrl(document.getElementById('txtDateClosed0'), event.clientX, event.clientY);"/>
                                                <input class="updown" type="button" value="+" onclick="_reg_restaurant_.addDaysClosed();" style="width: 25px;"/>
                                                <input class="updown" type="button" value="-" onclick="_reg_restaurant_.removeDaysClosed('tblDaysClosed0');" style="width: 25px;"/>
                                                <input type="hidden" name="hdnDaysClosedId0" id="hdnDaysClosedId0" value="0" />
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <?php } else {
                                    for ($i = 0; $i < count($db_tmp->daysClosed->record); $i++) {
                                        $obj = $db_tmp->daysClosed->record[$i];
                                ?>
                                <div id="dvDaysClosed<?php echo $i; ?>">
                                    <table id="tblDaysClosed<?php echo $i; ?>" cellpadding="1" cellspacing="1" border="0" width="100%">
                                        <tr>
                                            <td style="font-weight: bold;">
                                                <input id="txtDateClosed<?php echo $i; ?>" name="txtDateClosed<?php echo $i; ?>" class="inputbox" type="text" value="<?php echo ($obj->day_closed != '0000-00-00 00:00:00') ? date('m/d/Y', strtotime($obj->day_closed)) : ''; ?>" style="text-align: center; width: 100px;" readonly=readonly onclick="javascript:gfPop.fShowCalendarCtrl(this, event.clientX, event.clientY);"/>
                                                <img class="calendar" alt="calendar" src="libraries/calendar/cal.gif" style="cursor: pointer;" onclick="javascript:gfPop.fShowCalendarCtrl(document.getElementById('txtDateClosed<?php echo $i; ?>'), event.clientX, event.clientY);"/>
                                                <input class="updown" type="button" value="+" onclick="_reg_restaurant_.addDaysClosed();" style="width: 25px;"/>
                                                <input class="updown" type="button" value="-" onclick="_reg_restaurant_.removeDaysClosed('tblDaysClosed<?php echo $i; ?>');" style="width: 25px;"/>
                                                <input type="hidden" name="hdnDaysClosedId<?php echo $i; ?>" id="hdnDaysClosedId<?php echo $i; ?>" value="<?php echo $obj->id; ?>" />
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <?php } } ?>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <span style="font-weight: bold;"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_CUISINE') ?></span>
                            <div id="dvCuisine">
                                <?php
                                if (!isset($db_tmp) || count($db_tmp->cuisine->record) == 0) {
                                ?>    
                                <div id="dvCuisine0">
                                    <table id="tblCuisine0" cellpadding="1" cellspacing="1" border="0" width="100%">
                                        <tr>
                                            <td width="140px">
                                                <select class="inputbox" id="cboCuisine0" name="cboCuisine0" style="width: 200px;">
                                                    <?php echo ps_restaurant::getCuisineType(); ?>
                                                </select>
                                            </td>
                                            <td>
                                                <input class="updown" type="button" value="+" onclick="_reg_restaurant_.addCuisine();" style="width: 25px;"/>
                                                <input class="updown" type="button" value="-" onclick="_reg_restaurant_.removeCuisine('tblCuisine0');" style="width: 25px;"/>
                                                <input type="hidden" name="hdnCuisineId<?php echo $i; ?>" id="hdnCuisineId0" value="0" />
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <?php } else {
                                    for ($i = 0; $i < count($db_tmp->cuisine->record); $i++) {
                                        $obj = $db_tmp->cuisine->record[$i];
                                ?>
                                <div id="dvCuisine<?php echo $i; ?>">
                                    <table id="tblCuisine<?php echo $i; ?>" cellpadding="1" cellspacing="1" border="0" width="100%">
                                        <tr>
                                            <td width="140px">
                                                <select class="inputbox" id="cboCuisine<?php echo $i; ?>" name="cboCuisine<?php echo $i; ?>" style="width: 200px;">
                                                    <?php echo ps_restaurant::getCuisineType($obj->cuisine_id); ?>
                                                </select>
                                            </td>
                                            <td>
                                                <input class="updown" type="button" value="+" onclick="_reg_restaurant_.addCuisine();" style="width: 25px;"/>
                                                <input class="updown" type="button" value="-" onclick="_reg_restaurant_.removeCuisine('tblCuisine<?php echo $i; ?>');" style="width: 25px;"/>
                                                <input type="hidden" name="hdnCuisineId<?php echo $i; ?>" id="hdnCuisineId<?php echo $i; ?>" value="<?php echo $obj->id; ?>" />
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <?php 
                                    } 
                                } ?>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                             <span style="font-weight: bold;"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_DESCRIPTIONS') ?></span>
                             <br>
                             <textarea cols="50" rows="3" style="height: 60px;" name="vendor_descriptions" id="vendor_descriptions"><?php (isset($db_tmp)) ? $db_tmp->p("vendor_descriptions") : ''; ?></textarea>
                        </td>
                    </tr>
                    <?php  if($submitType == 'restaurantAdd'){    ?>
                    <tr>
                        <td colspan="2">
                        <span style="font-weight: bold;">Terms & Conditions</span>
                        <br>
                            <textarea cols="50" rows="3" style="width: 397px;height: 60px;text-align: left;font-size: 10px;overflow-y:scroll;" readonly="readonly" name="vendor_descriptions" id="vendor_descriptions">I agree that Menutise.com, as independent contractor, shall act as my agent in marketing my restaurant and in advertising, selling, and collecting revenue on behalf of my restaurant. Menutise.com shall be a disclosed agent to the public in all respects. 

&#x2022 I can cancel at any time and I promise, as does Menutise.com, to rectify any remaining account balances within 30 days of cancellation.  
&#x2022 I will notify my phone staff they will be recorded. 
&#x2022 I agree to pay the advertising fee circled above for each ?order? (term defined as food and beverage subtotal, including delivery fee, placed through Menutise.com to my restaurant). 
&#x2022 In the event orders are placed by telephone (using contact information from Menutise.com) the fee shall be determined by my restaurant?s monthly fee average as determined from month to month. 
&#x2022 I agree my restaurant is obligated to notify Menutise.com in writing of any changes to my restaurant?s menu, and my restaurant will protect, defend, and indemnify Menutise.com from any and all claims brought against Menutise.com as a result of any failure by my restaurant with respect to such notification. 
&#x2022 I agree, as does Menutise.com, specifically with respect to sales tax, that Menutise.com shall compute the sales tax charged pursuant to instructions provided by my restaurant, shall collect the sales tax solely as an agent on behalf of my restaurant, shall pay such amount collected to my restaurant, and my restaurant shall be solely responsible for verifying the amount collected, filing the appropriate sales tax returns, and remitting the proper amount to the appropriate taxing authorities. For the purpose of such sales tax payments, my sales tax registration number is listed above. For purposes of this Sign-up Form, sales tax shall include any sales, use, privilege, gross receipts, restaurant, excise or other tax due in relation to the sale of food or drink by my restaurant. 
&#x2022 I agree that my restaurant is responsible for all liability associated with the sale of food and any drink, including alcohol, by my restaurant, including, without limitation, computation of payment of sales tax to the appropriate taxing authority; delivery service and parking accessibility if any; compliance with appropriate health codes with respect to preparation of food; and all matters concerning quality and condition of the food; and further, my restaurant will protect, defend, and indemnify Menutise.com from any and all claims brought against Menutise.com as a result of any failure by my restaurant with respect to the foregoing. 
&#x2022 I authorize Menutise.com to secure a domain name for my restaurant (named herein) to develop and/or improve and provide web page maintenance for my restaurant for advertising purposes (?the Project?) and I agree to pay the fee of $1.00 per order plus credit card processing fees for orders originating from this web page. Alternatively, I authorize Menutise.com to redesign a restaurant website that I provide, including but not limited to coordinating the redirection of the address to the new host. Menutise.com may access, on my behalf any and all accounts and hosting services to access and complete the Project. I further agree that if Menutise.com so chooses, Menutise.com is authorized to publicize their completed Project (collectively, ?Website?) to Web search engines as well as other Web directories and indexes. 
&#x2022 I agree that any materials submitted for publication are owned by me, or that I have permission from the rightful owner to use each of these elements. I further agree that the material submitted will not contain anything leading to an abusive or unethical use of the hosting service or Menutise.com. I agree to indemnify and hold harmless Menutise.com from any and all claims or suits resulting from Menutise?s publication of material or use of those materials. This includes, but is not limited to infringing on the proprietary rights of a third party, and delivering any defective product or misinformation which is detrimental to another person, organization, or business. From time to time governments enact laws and levy taxes and tariffs affecting Internet electronic commerce. I agree I am solely responsible for complying with such laws, taxes, and tariffs as they relate to the Website, if any, and will hold harmless, protect, and defend Menutise.com from any claim, suit, penalty, tax, or tariff arising from my exercise of Internet electronic commerce. 
&#x2022 I agree that Menutise.com does not warrant that the functions of the Website, if any, will meet my expectations of site traffic or resulting business or that the operation of the web pages will be uninterrupted and/or error-free. Menutise.com will not be held responsible for occasional downtime of the website due to line interruptions and/or other instances beyond Menutise.com?s control. 
&#x2022 Copyright to the finished assembled work of web pages and graphics produced by Menutise.com, on the Website, if any, shall be vested with Menutise.com. This ownership is to include, design, photos, graphics, source code, work-up files, text, and any program(s) specifically designed or purchased on my behalf for completion of the Project. 
&#x2022 I represent that I am authorized to enter into this Sign-Up Form. This agreement shall be governed by and interpreted in accordance with the laws of New Jersey without regard to principles of conflicts of laws. Please see Menutise?s Terms of Use at: www.Mentise.com/legal/, which are subject to change. The terms and conditions thereto, shall bind my restaurant by my restaurant continuing participation and receipt of orders. 
&#x2022 I, the undersigned, hereby agree to the terms, conditions and stipulations of this agreement on behalf of my restaurant, as named herein. Until further written notice, I, the undersigned, hereby provides my unlimited consent, authorization, and assignment to Menutise.com all rights and privileges necessary or useful to manage all information, including but not limited to menus, pertaining to and describing my restaurant in my name, place, and stead on all 3rd party websites and online data services. 
Where available, I may sign the form electronically, by selecting the ?I Accept? button. In selecting the ?I Accept Button?, the electronic signature (?E-Signature?) is the legal equivalent of my manual signature on this sign up form. I agree that no certification authority or other third party verification is necessary to validate my E-Signature and that the lack of such will not in any way affect the enforceability of my E-Signature or any resulting contract between me and Menutise.com. 

                            </textarea>
                            <br> 
                            <input style="height: 10px;" type="checkbox" id="chkAgree" name="chkAgree" onclick="_reg_restaurant_.agreeChanged();" />
                            <label for="chkAgree"><?php echo $VM_LANG->_('PHPSHOP_RESTAURANT_REG_FORM_RES_AGREE') ?></label>
                            <a href="images/stories/MenutiseServiceTerms.pdf">download</a>
                        </td>
                    </tr>
                    <?php }?>
                    <tr>
                        <td colspan="2" align="center">
                            <br>
                            <input id="btnReg" class="button" name="btnReg" type="button" value="<?php if($submitType == 'restaurantAdd'){echo $VM_LANG->_('BUTTON_SEND_REG');}else{echo $VM_LANG->_('BUTTON_SEND_EDIT');} ?>" onclick="_reg_restaurant_.saveData();"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
    <input type="hidden" name="Itemid" value="'. $sess->getShopItemid() .'" />
    <input type="hidden" name="option" value="com_virtuemart" />
    <input type="hidden" name="<?php echo $validate; ?>" value="1" />
    <input type="hidden" name="func" value="<?php echo $submitType; ?>" />
    <input type="hidden" name="page" value="checkout.index" />
    <input type="hidden" name="hdnVendorId" id="hdnVendorId" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_id") : 0; ?>" />
    <input type="hidden" name="hdnKitchen" id="hdnKitchen" value="" />
    <input type="hidden" name="hdnDayClosed" id="hdnDayClosed" value="" />
    <input type="hidden" name="hdnCuisine" id="hdnCuisine" value="" />
    <input type="hidden" name="hdnUserId" id="hdnUserId" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_user_id") : 0; ?>" />
    <input type="hidden" name="hdnPassword" id="hdnPassword" value="<?php (isset($db_tmp)) ? $db_tmp->p("vendor_password") : ''; ?>" />
    <input type="hidden" name="hdnCategoryParentId" id="hdnCategoryParentId" value="<?php (isset($db_tmp)) ? $db_tmp->p("category_parent_id") : 0; ?>" />
    <input type="hidden" name="hdnCategoryChildId" id="hdnCategoryChildId" value="<?php (isset($db_tmp)) ? $db_tmp->p("category_child_id") : 0; ?>" />
</form>